<!-- 新闻查看更多 -->
<template>
  <!-- 院部新闻开始 -->
  <div class="news">
      <more title1="院部新闻"></more>
      <div class="news-content">
        <div class="news1" v-for="(item, index) in newsList" :key="item.id">
          <div class="news-left">
            <img class="image3" :src="item.image" alt="" />
            <div class="none1">{{ item.title }}</div>
          </div>
          <div class="news-right">
            <div class="top top-none">
              {{ item.title }}
            </div>
            <div class="top top-none1">
              传承八一精神 凝聚奋进力量|旅游与服务系第一第二党支部开展主题...
            </div>
            <div class="center">
              <div class="border"></div>
              <div class="time">{{ item.create_time }}</div>
            </div>
            <div class="bottom bottom-none">
              {{ item.abstract }}
            </div>
            <div class="bottom bottom-none1">
              传承八一精神
              凝聚奋进力量|旅游与服务系第一第二党支部开展主题，传承八一精神...
            </div>
            <div class="bottom-img">
              <div class="bottom-left">
                <img src="../../assets/33上一页、前一页.png" alt="" class="img-left" />
                <img src="../../assets/33上一页、前一页.png" alt="" class="img-right" />
            </div>
            <div class="bottom-right">
                <span>{{ index + 1 }}</span
                >/{{ newsList.length }}
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="news-bottom">
        <div class="bottom-content" v-for="item in 3" :key="item">
          <div class="content-top">
            传承八一精神 凝聚奋进力量 | 旅游与服务系第一第二党支部开展主题...
          </div>
          <div class="content-bottom">
            <img src="../../assets/33上一页、前一页.png" alt="" />
            2022-11-02
          </div>
        </div>
      </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { Swiper, SwiperSlide } from 'swiper/vue';
import { Pagination } from 'swiper/modules';
import $ from "jquery";
// 引入Swiper样式
import 'swiper/css';
import 'swiper/css/pagination';
import { getnsList } from "../../api/news";
const newsList = ref();
const getnewsList = async () => {
  // 同步调用
  const {
    data: {
      data: { list },
    },
  } = await getnsList();
  // console.log();
  // index.value = index1 + 1;
  newsList.value = list;
  $(function () {
    $(".news1:first").show().siblings(".news1").hide();
    var index = 0;
    $(".img-right").click(() => {
      index++;
      console.log(index);
      if (index < 3) {
        $(".news1").eq(index).show().siblings(".news1").hide();
      } else {
        index = -1;
      }
    });
    $(".img-left").click(() => {
      index--;
      if (index >= 0) {
        $(".news1").eq(index).show().siblings(".news1").hide();
      } else {
        index = 3;
      }
    });
    $(".none2").click(function () {
      var bElement = $(".uls");
      if (bElement.is(":visible")) {
        bElement.hide();
      } else {
        bElement.show();
      }
    });
  });
};
getnewsList(); // 新闻列表
const modules = [Pagination];
</script>

<style scoped lang="scss">
.news {
      width: 95%;
      margin: auto;

      .news-content {
        .news1 {
          width: 100%;
          display: flex;
          text-align: center;
          justify-content: space-between;

          .news-left {
            width: 49%;
            height: 350px;

            .none1 {
              display: none;
            }

            .image3 {
              width: 100%;
              height: 350px;
            }
          }

          .news-right {
            height: 350px;
            border: 1px solid #f1f1f1;
            border-radius: 10px;
            width: 49%;

            .top {
              font-weight: bold;
              text-align: left;
              padding: 15px;
              font-size: 24px;
              height: 60px;
            }

            .top-none1 {
              display: none;
            }

            .center {
              display: flex;
              align-items: center;
              padding: 15px;
              justify-content: space-between;

              .border {
                width: 70%;
                border-bottom: 2px solid #e3e3e3;
              }

              .time {
                color: #d33939;
                padding: 10px;
                width: 30%;
              }
            }

            .bottom {
              text-align: left;
              padding: 15px;
              color: #000;
              font-size: 20px;
              z-index: 999;
              height: 120px;
            }

            .bottom-none1 {
              display: none;
            }

            .bottom-img {
              display: flex;
              justify-content: space-between;
              padding-top: 15px;
              padding-left: 15px;
              padding-right: 15px;

              .bottom-left {
                img {
                  width: 40px;
                  height: 40px;
                }

                img:nth-child(1) {
                  transform: rotate(180deg);
                  margin-left: 10px;
                  margin-right: 10px;
                }

                img:hover {
                  filter: drop-shadow(0 0 0 red);
                }
              }

              .bottom-right {
                span {
                  color: #c60000;
                  font-size: 24px;
                }
              }
            }
          }
        }
      }

      .news-bottom {
        display: flex;
        justify-content: space-between;
        margin-top: 40px;
        @media (max-width:475px) {
         
            display: block;
          
        }
        .bottom-content {
          width: 32%;
          border: 1px solid #f8f8f8;
          padding: 15px;

          .content-top {
            font-size: 18px;
          }

          .content-bottom {
            display: flex;
            justify-content: right;
            margin-top: 20px;
            margin-bottom: 20px;
            color: #d54646;

            img {
              width: 20px;
            }
          }
        }

        .bottom-content:hover {
          background-color: #edabac;
        }
      }
    }
    @media (max-width:475px) {
        .news {
      width: 90%;
      margin: auto;

      .news-content {
        .news1 {
         
          display: block;
          .news-left {
            width: 100%;
            // border: 1px solid red;
            img {
              width: 100%;
              height: 200px;
            }

            .none1 {
              display: none;
            }
          }

          .news-right {
            width: 100%;
            margin-top: 20px;
            border: 1px solid #f2f2f2;
            padding: 10px;

            .top-none {
              display: none;
            }

            .center {
              display: block;
              align-items: center;
              justify-content: space-between;

              .border {
                width: 60%;
              
                border-bottom: 2px solid #e3e3e3;
              }

              .time {
                width: 50%;
                margin-left: 200px;
                color: blue;
                display: block;
                font-size: 20px;
              }
            }

            .bottom-none {
              display: none;
            }

            .bottom {
              text-align: left;
              color: #000;
              font-size: 18px;
              z-index: 999;
            }

            .bottom-img {
              display: flex;
              justify-content: space-between;
              padding-top: 15px;
              // padding-left: 15px;
              padding-right: 15px;

              .bottom-left {
                img {
                  width: 30px;
                  height: 30px;
                }

                img:nth-child(1) {
                  transform: rotate(180deg);
                  margin-left: 10px;
                  margin-right: 10px;
                }

                img:hover {
                  filter: drop-shadow(0 0 0 red);
                }
              }

              .bottom-right {
                span {
                  color: #c60000;
                  font-size: 24px;
                }
              }
            }
          }
        }
      }

      .news-bottom {
        margin-top: 40px;

        .bottom-content {
          width: 100%;
          border: 1px solid #f2f2f2;
          padding: 10px;
          margin-top: 40px;

          .content-top {
            font-size: 16px;
          }

          .content-bottom {
            display: flex;
            justify-content: right;
            margin-top: 20px;
            margin-bottom: 20px;
            color: #d54646;

            img {
              width: 20px;
            }
          }
        }

        .bottom-content:hover {
          background-color: #edabac;
        }
      }
    }

    }
</style>